diff options
| author | Adam Soltys <[email protected]> | 2025-03-15 21:27:44 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2025-03-15 21:27:44 -0700 |
| commit | f22464cf997b72d5fd99ddabb152401d7ef71ecb (patch) | |
| tree | db55d71b7774d3dd4e46158cd5ff80fd2c962cba /src/routes/(app)/fund/[id]/access | |
| parent | b9723d50e2be0d04715289b656ff1ef1c24f6248 (diff) | |
| download | coinos-ui-fund-access.tar.gz coinos-ui-fund-access.zip | |
fund uifund-access
Diffstat (limited to 'src/routes/(app)/fund/[id]/access')
| -rw-r--r-- | src/routes/(app)/fund/[id]/access/+page.server.ts | 26 | ||||
| -rw-r--r-- | src/routes/(app)/fund/[id]/access/+page.svelte | 38 |
2 files changed, 59 insertions, 5 deletions
diff --git a/src/routes/(app)/fund/[id]/access/+page.server.ts b/src/routes/(app)/fund/[id]/access/+page.server.ts index 9a8a9dbc..c38cb29b 100644 --- a/src/routes/(app)/fund/[id]/access/+page.server.ts +++ b/src/routes/(app)/fund/[id]/access/+page.server.ts @@ -1,3 +1,25 @@ -export const load = async () => { - return { managers: [] }; +import { auth, fd, get, post } from "$lib/utils"; +import { fail } from "@sveltejs/kit"; + +export const load = async ({ params: { id } }) => { + const managers = await get(`/fund/${id}/managers`); + return { managers, id }; +}; + +export const actions = { + default: async ({ cookies, request }) => { + const form = await fd(request); + + try { + console.log("SUBMITTING", form); + const managers = await post("/fund/managers", form, auth(cookies)); + + console.log(managers); + + return { managers }; + } catch (e) { + const { message } = e as Error; + return fail(400, { message }); + } + }, }; diff --git a/src/routes/(app)/fund/[id]/access/+page.svelte b/src/routes/(app)/fund/[id]/access/+page.svelte index 754ddf87..f18d6357 100644 --- a/src/routes/(app)/fund/[id]/access/+page.svelte +++ b/src/routes/(app)/fund/[id]/access/+page.svelte @@ -1,8 +1,19 @@ <script> + import { fail, post } from "$lib/utils"; + import { enhance } from "$app/forms"; + import { t } from "$lib/translations"; import Avatar from "$comp/Avatar.svelte"; let { data } = $props(); - let { managers } = $derived(data); + let { id, managers } = $derived(data); + let username = $state(); + let del = async ({ id }) => { + try { + await post("/post/fund/access/delete", { id }); + } catch (e) { + fail(e.message); + } + }; </script> <div class="container px-4 max-w-4xl mx-auto mt-10 space-y-5"> @@ -15,15 +26,36 @@ </h1> {#each managers as c} - <a href={`/pay/${c.username}`} class="contents"> - <div class="flex hover:bg-base-200 p-2"> + <a href={`/${c.username}`} class="contents"> + <div class="flex hover:bg-base-200 p-2 items-center"> <Avatar user={c} size={20} disabled={true} /> <div class="my-auto text-left"> <p class="ml-1 text-lg break-words">{c.username}</p> </div> + <button onclick={() => del(c)} class="ml-auto"> + <iconify-icon icon="ph:trash-bold" width="32"></iconify-icon> + </button> </div> </a> {/each} + + <form method="post" use:enhance class="space-y-2"> + <input type="hidden" name="id" value={id} /> + <input + name="username" + bind:value={username} + placeholder={$t("funds.username")} + /> + <button type="submit" class="btn"> + <iconify-icon icon="ph:plus-bold" width="32"></iconify-icon> + {$t("funds.addManager")} + </button> + </form> + + <a href={`/fund/${id}`} class="btn"> + <iconify-icon icon="ph:arrow-left-bold" width={32}></iconify-icon> + {$t("funds.returnToFund")}</a + > </div> </div> </div> |
